import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/goods_list_model.dart';

GoodsListModel $GoodsListModelFromJson(Map<String, dynamic> json) {
  final GoodsListModel goodsListModel = GoodsListModel();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    goodsListModel.id = id;
  }
  final int? shopId = jsonConvert.convert<int>(json['shop_id']);
  if (shopId != null) {
    goodsListModel.shopId = shopId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    goodsListModel.name = name;
  }
  final String? coverImage = jsonConvert.convert<String>(json['cover_image']);
  if (coverImage != null) {
    goodsListModel.coverImage = coverImage;
  }
  final String? price = jsonConvert.convert<String>(json['price']);
  if (price != null) {
    goodsListModel.price = price;
  }
  final String? marketPrice = jsonConvert.convert<String>(json['market_price']);
  if (marketPrice != null) {
    goodsListModel.marketPrice = marketPrice;
  }
  final String? pointsPrice = jsonConvert.convert<String>(json['points_price']);
  if (pointsPrice != null) {
    goodsListModel.pointsPrice = pointsPrice;
  }
  final String? rewardPoints = jsonConvert.convert<String>(json['reward_points']);
  if (rewardPoints != null) {
    goodsListModel.rewardPoints = rewardPoints;
  }
  return goodsListModel;
}

Map<String, dynamic> $GoodsListModelToJson(GoodsListModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['shop_id'] = entity.shopId;
  data['name'] = entity.name;
  data['cover_image'] = entity.coverImage;
  data['price'] = entity.price;
  data['market_price'] = entity.marketPrice;
  data['points_price'] = entity.pointsPrice;
  data['reward_points'] = entity.rewardPoints;
  return data;
}

extension GoodsListModelExtension on GoodsListModel {
  GoodsListModel copyWith({
    int? id,
    int? shopId,
    String? name,
    String? coverImage,
    String? price,
    String? marketPrice,
    String? pointsPrice,
    String? rewardPoints,
  }) {
    return GoodsListModel()
      ..id = id ?? this.id
      ..shopId = shopId ?? this.shopId
      ..name = name ?? this.name
      ..coverImage = coverImage ?? this.coverImage
      ..price = price ?? this.price
      ..marketPrice = marketPrice ?? this.marketPrice
      ..pointsPrice = pointsPrice ?? this.pointsPrice
      ..rewardPoints = rewardPoints ?? this.rewardPoints;
  }
}